


(defun load-start-states (sentence )
  (dolist (i sentence)
  ;(write-line (format nil "(part_b ~A ~A)" i (TruthValue  i)))
  ;(write-line (format nil "(part_d ~A )" i ))
  (write-line (format nil "(part_d ~A ~A)" i (wfp-checkerFOL i)))
  ))


(load-start-states start-state)
(load-start-states goal-state)
(load-start-states operators)
(load-operators operators)


;Initial State:
(setf start-state
  '((S |a| |u|)         ;(side cat left)
    (S |b| |u|)         ;(side rat left)
    (S |c| |u|)         ;(side grain left)
    (S |d| |u|)         ;(side farmer left)
    (S |e| |u|)         ;(side boat left)
))


;Initial State:
(setf goal-state
  '((S |a| |v|)         ;(side cat right)
    (S |b| |v|)         ;(side rat right)
    (S |c| |v|)         ;(side grain right)
    (S |d| |v|)         ;(side farmer right)
    (S |e| |v|)         ;(side boat right)
))


(defun load-operators (sentence )
  (dolist (i sentence)
  ;(write-line (format nil "(part_d ~A )" i ))
  (write-line (format nil "============================"))
    (dolist (x i)
        (write-line (format nil "~A" x ))
        (write-line (format nil "(part_d ~A ~A)" x (wfp-checkerFOL x)))
      )
  ))

;======================================
;Operators
(setf operators
  '(
    ;ACTION
    ((F)                   ; (boatfull)
    ;PRECOND
    (AND (I |d|) (OR (AND (I |a|) (I |b|))    ; (and (inboat farmer) (or (and (inboat cat) (inboat rat)
                    (AND (I |c|) (I |b|))    ;                          (and (inboat grain) (inboat rat))
                    (AND (I |c|) (I |a|)))) ;                          (and (inboat grain) (inboat)))))
    ;ADD
    ((F))                  ; (boatfull) - The Boat is full
    ;DELETE
    ((N)))                 ; (boatnotfull) - The boat is not full

    ;ACTION
    ((M |x|)                 ; (moveboat) - move boat to x side
    ;PRECOND
    (AND (S |e| |y|) (J |d|))  ; ((side boat Y) (inboat farmer))
    ;ADD
    ((S |e| |x|))              ;  ((side boat X))
    ;DELETE
    ((S |e| |y|)))       ; ((side boat y)))
    
    ;ACTION
    ((U |x| |y|)          ; (unload X Y)    - unload x item on y side
    ;PRECOND
    (AND (S |e| |y|) (I |x|))    ; (side boat Y) (inboat X))
    ;ADD
    ((S |x| |y|))              ; (side X Y))
    ;DELETE
    ((I |x|) (N)))           ; ((I X) (boatnotfull)))

    ;ACTION
    ((L |x| |y|)               ; load X Y) - unload x item from y side
    ;PRECOND
    (AND (S |e| |y|) (S |x| |y|))  ; (side boat Y) (side X Y))
    ;ADD
    ((I |x|))                ; ((I X))
    ;DELETE
    ((S |x| |y|)))             ; ((side X Y)))

    ;ACTION
    ((E |a| |b| |z|)      ; (eats cat rat z) - cat eats rat  on Z side if farmer is not on Z side
    ;PRECOND
    (AND (S |d| |y|) (S |a| |z|) (S |b| |z|))     ; (side farmer Y) (side X Z) (size Y Z))
    ;ADD
    (())
    ;DELETE
    ((S |b| |z|)))  ; side Y Z)) - Y is eaten, and therefore on no side. you will never reach goal becuase Y is missing.

))